package com.acme.bankapp.domain.bank;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * Bank.
 * 
 */
public class Bank {
	private Set<Client> clients = new LinkedHashSet<Client>();

	/**
	 * Returns all clients of the bank.
	 * 
	 * @return set of clients
	 */
	public Set<Client> getClients() {
		return new LinkedHashSet<Client>(clients);
	}

	/**
	 * Adds new client to the bank.
	 * 
	 * @param client
	 *            client to add
	 */
	public void addClient(Client client) {
		clients.add(client);
	}

	/**
	 * Returns all accounts in the bank.
	 * 
	 * @return set of accounts
	 */
	public Set<Account> getAccounts() {
		Set<Account> accounts = new LinkedHashSet<Account>();

		for (Client client : clients) {
			accounts.addAll(client.getAccounts());
		}

		return accounts;
	}
}
